package com.browan.constellation;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.KeyEvent;

public abstract class BaseActivity extends Activity
{

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
//		String sdk = android.os.Build.VERSION.SDK;
//	
		if (keyCode == KeyEvent.KEYCODE_BACK)
		{
			exitDialog();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	private boolean isExit;

	protected boolean exitDialog()
	{
		isExit = true;
		new AlertDialog.Builder(this).setTitle("退出").setMessage("确定退出程序？").setPositiveButton("是", new OnClickListener()
		{
			@Override
			public void onClick(DialogInterface dialog, int which)
			{
				BaseActivity.this.finish();
			}
		}).setNegativeButton("否", null).setCancelable(false).create().show();
		return isExit;
	};

}